from matplotlib import pyplot as plt
from matplotlib import ticker
from datetime import datetime

plt.figure(figsize=(16, 8))
x = [datetime( 2024,1, 5), datetime(2024, 1, 6), datetime( 2024,1, 7), datetime(2024,1, 8), datetime( 2024,1, 9), datetime(2024,1, 10),datetime(2024,1, 11),datetime( 2024,1, 12),datetime(2024,1, 13)]
y = [1,0.8,0.6,0.5,0.4,0.25,0.15,0.1,0]
x2 = [datetime( 2024,1, 5), datetime(2024, 1, 6),datetime(2024, 1, 7),datetime(2024, 1, 8),datetime(2024, 1, 9),datetime(2024, 1, 10),datetime(2024, 1, 11),datetime(2024, 1, 12),datetime(2024, 1, 13)]
y2 = [1,0.75,0.65,0.5,0.35,0.25,0.15,0.05,0]

#绘图
plt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签
plt.rcParams['axes.unicode_minus']=False

plt.switch_backend('TkAgg')
fig, ax = plt.subplots()
line1 =ax.plot(x, y,label = '理想工作量')
ax.yaxis.set_major_formatter(ticker.PercentFormatter(xmax=1, decimals=1))
line2 =ax.plot(x2,y2,'r',label='实际工作量')
ax.yaxis.set_major_formatter(ticker.PercentFormatter(xmax=1, decimals=1))
plt.title("项目燃尽图",loc="center")
plt.xlabel("时间",fontsize=13)
plt.ylabel("剩余工作量",fontsize=13)
plt.legend( loc='upper right')
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()

